package com.csk.zsk.compents.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.csk.zsk.commons.entity.IdEntity;
@Entity
@Table(name = "COMIC_CHAPTERS")
@JsonIgnoreProperties({ "comic","comicPagesList" })
public class ComicChapters extends IdEntity {
	private String name;
	private String url;
	private Comic comic;
	private Integer num;
	private List<ComicPages> comicPagesList;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "comicid")
	public Comic getComic() {
		return comic;
	}
	public void setComic(Comic comic) {
		this.comic = comic;
	}
	
	@OneToMany(mappedBy = "comicChapters", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY, orphanRemoval = true)
	@Fetch(FetchMode.SUBSELECT)
	@OrderBy(value = "num")
	public List<ComicPages> getComicPagesList() {
		return comicPagesList;
	}
	public void setComicPagesList(List<ComicPages> comicPagesList) {
		this.comicPagesList = comicPagesList;
	}
	public Integer getNum() {
		return num;
	}
	public void setNum(Integer num) {
		this.num = num;
	}
	
	
	
	
}
